// 5. 编译时多项式求值
// 编译时多项式求值 - 用于图像滤波器系数计算
template <typename T, T... Coeffs>
struct Polynomial;

template <typename T, T C0>
struct Polynomial<T, C0>
{
    static constexpr T eval(T x) { return C0; }
};

template <typename T, T C0, T C1, T... Cs>
struct Polynomial<T, C0, C1, Cs...>
{
    static constexpr T eval(T x)
    {
        return C0 + x * Polynomial<T, C1, Cs...>::eval(x);
    }
};

// 使用示例 - 高斯核计算
template <typename T, int KernelSize>
class GaussianKernel
{
    static constexpr T sigma = 1.0;

    template <int I>
    static constexpr T compute_coefficient()
    {
        constexpr T x = static_cast<T>(I - KernelSize / 2);
        constexpr T exponent = -(x * x) / (2 * sigma * sigma);
        return std::exp(exponent) / (sigma * std::sqrt(2 * M_PI));
    }

public:
    static constexpr std::array<T, KernelSize> get_kernel()
    {
        std::array<T, KernelSize> kernel = {};
        for (int i = 0; i < KernelSize; ++i)
        {
            kernel[i] = compute_coefficient<i>();
        }
        return kernel;
    }
};